home *** CD-ROM | disk | FTP | other *** search
/ Chip 1999 June / Chip Haziran 1999.iso / program / share / jtp / _SETUP.1 / JTermScript.txt < prev    next >
Encoding:
Text File  |  1998-07-21  |  17.5 KB  |  334 lines

  1. #define pt_DEFAULT                  0
  2. #define pt_COMMENT_LINE             1
  3. #define pt_IDENTIFIER               2
  4. #define pt_STRING                   3
  5. #define pt_NUMBER                   4
  6. #define pt_COMMENT                  5
  7. #define pt_HEXNUMBER                6
  8. #define pt_RESERVED                 7
  9. #define pt_COMMENT_BRACE            8
  10. #define pt_COMMENT_STAR             9
  11. #define pt_SYMBOL                   10
  12. #define pt_CHAR_DECIMAL             11
  13. #define pt_CHAR_HEX                 12
  14.  
  15.  
  16. #define pt_SEMICOLON                20
  17. #define pt_PROPERTY                 21
  18. #define pt_DEFAULT_TOKEN            22
  19. #define pt_READ                     23
  20. #define pt_WRITE                    24
  21. #define pt_STORED                   25
  22. #define pt_EXPORTS                  26
  23. #define pt_NAME                     27
  24. #define pt_INDEX                    28
  25. #define pt_RESIDENT                 29
  26.  
  27. #define _non_alpha_                 '[^_A-Za-z0-9]'
  28. #define _all_chars_                 '[\x00-\xFF]'
  29. #define _dec_digit_                 '[0-9]'
  30. #define _hex_digit_                 '[a-fA-F0-9]'
  31. #define _no_chars_                  '[]'
  32. #define _dont_care_                 _all_chars_
  33. #define _DEFAULT_BACKGROUND         clWhite
  34. #define _DEFAULT_FOREGROUND         clBlack
  35.  
  36. #define ss_START                    0
  37. #define ss_PROPERTY                 1
  38. #define ss_EXPORTS                  2
  39.  
  40.  
  41.  
  42. //--------------------------------------------------------------------------------------------------------------------
  43. //
  44. // %%language section
  45. //
  46. // Header section. Describes the textual name of the language, case sensitivity and options used by the language.
  47. //
  48. %%language
  49. Name                      = 'J-Term Pro Script'
  50. Case                      = __INSENSITIVE
  51. Options                   = __DEFAULT_OPTIONS
  52. WordWrapColumn            = _EDGE
  53. Gutter                    = _DEFAULT_GUTTER
  54. Anchor                    = _DEFAULT_START_ANCHOR
  55. ExampleText               = 'var a: string;\n\
  56.                             \    b: integer;\n\
  57.                             \begin\n\
  58.                             \  b := 0;\n\
  59.                             \  a := \'\';\n\
  60.                             \  while b < 10 do begin\n\
  61.                             \    a := a + IntoToStr(b);\n\
  62.                             \    inc(b);\n\
  63.                             \   end;\n\
  64.                             \end.\n'
  65. EditableStyles              ('Reserved word', pt_RESERVED),
  66.                             ('Comment',       pt_COMMENT),
  67.                             ('Identifier',    pt_IDENTIFIER),
  68.                             ('String',        pt_STRING),
  69.                             ('Number',        pt_NUMBER),
  70.                             ('Symbols',       pt_SYMBOL),
  71.                             ('Default',       pt_DEFAULT)
  72.  
  73.  
  74.  
  75.  
  76. //--------------------------------------------------------------------------------------------------------------------
  77. //
  78. // %%words section
  79. //
  80. // Used to specify simple languge keywords. These are constant value lexemes that always contain the same characters
  81. // and only require the end style to be specified. The words present here will always be tried first. If they fail
  82. // then the entries in the %%tokens section will be allowed to try a match.
  83. //
  84. // %%words table entries have 3 columns:
  85. //     Column 1          Quoted string giving the characters that make up the word
  86. //     Column 2          Quoted string that specifies how the word is terminated
  87. //     Column 3          Token value returned when word is recognised
  88. //
  89. %%words
  90. '\/\/'                  _dont_care_                 pt_COMMENT_LINE
  91. '{'                     _dont_care_                 pt_COMMENT_BRACE
  92. '(*'                    _dont_care_                 pt_COMMENT_STAR
  93. ':='                    _dont_care_                 pt_SYMBOL
  94. '+'                     _dont_care_                 pt_SYMBOL
  95. '-'                     _dont_care_                 pt_SYMBOL
  96. '*'                     _dont_care_                 pt_SYMBOL
  97. '\/'                    _dont_care_                 pt_SYMBOL
  98. '='                     _dont_care_                 pt_SYMBOL
  99. '<>'                    _dont_care_                 pt_SYMBOL
  100. '<'                     _dont_care_                 pt_SYMBOL
  101. '>'                     _dont_care_                 pt_SYMBOL
  102. '<='                    _dont_care_                 pt_SYMBOL
  103. '>='                    _dont_care_                 pt_SYMBOL
  104. '('                     _dont_care_                 pt_SYMBOL
  105. ')'                     _dont_care_                 pt_SYMBOL
  106. '['                     _dont_care_                 pt_SYMBOL
  107. ']'                     _dont_care_                 pt_SYMBOL
  108. '.'                     _dont_care_                 pt_SYMBOL
  109. '..'                    _dont_care_                 pt_SYMBOL
  110. '^'                     _dont_care_                 pt_SYMBOL
  111. ','                     _dont_care_                 pt_SYMBOL
  112. ';'                     _dont_care_                 pt_SEMICOLON       [ss_START ss_PROPERTY]
  113. ':'                     _dont_care_                 pt_SYMBOL
  114. '@'                     _dont_care_                 pt_SYMBOL
  115. '#'                     _dec_digit_                 pt_CHAR_DECIMAL
  116. '#$'                    _hex_digit_                 pt_CHAR_HEX
  117. 'and'                   _non_alpha_                 pt_RESERVED
  118. 'array'                 _non_alpha_                 pt_RESERVED
  119. 'begin'                 _non_alpha_                 pt_RESERVED
  120. 'case'                  _non_alpha_                 pt_RESERVED
  121. 'const'                 _non_alpha_                 pt_RESERVED
  122. 'div'                   _non_alpha_                 pt_RESERVED
  123. 'do'                    _non_alpha_                 pt_RESERVED
  124. 'downto'                _non_alpha_                 pt_RESERVED
  125. 'else'                  _non_alpha_                 pt_RESERVED
  126. 'end'                   _non_alpha_                 pt_RESERVED
  127. 'false'                 _non_alpha_                 pt_RESERVED
  128. 'file'                  _non_alpha_                 pt_RESERVED
  129. 'for'                   _non_alpha_                 pt_RESERVED
  130. 'forward'               _non_alpha_                 pt_RESERVED
  131. 'function'              _non_alpha_                 pt_RESERVED
  132. 'goto'                  _non_alpha_                 pt_RESERVED
  133. 'if'                    _non_alpha_                 pt_RESERVED
  134. 'in'                    _non_alpha_                 pt_RESERVED
  135. 'label'                 _non_alpha_                 pt_RESERVED
  136. 'mod'                   _non_alpha_                 pt_RESERVED
  137. 'nil'                   _non_alpha_                 pt_RESERVED
  138. 'not'                   _non_alpha_                 pt_RESERVED
  139. 'of'                    _non_alpha_                 pt_RESERVED
  140. 'or'                    _non_alpha_                 pt_RESERVED
  141. 'procedure'             _non_alpha_                 pt_RESERVED
  142. 'program'               _non_alpha_                 pt_RESERVED
  143. 'record'                _non_alpha_                 pt_RESERVED
  144. 'repeat'                _non_alpha_                 pt_RESERVED
  145. 'set'                   _non_alpha_                 pt_RESERVED
  146. 'string'                _non_alpha_                 pt_RESERVED
  147. 'then'                  _non_alpha_                 pt_RESERVED
  148. 'to'                    _non_alpha_                 pt_RESERVED
  149. 'true'                  _non_alpha_                 pt_RESERVED
  150. 'type'                  _non_alpha_                 pt_RESERVED
  151. 'until'                 _non_alpha_                 pt_RESERVED
  152. 'var'                   _non_alpha_                 pt_RESERVED
  153. 'while'                 _non_alpha_                 pt_RESERVED
  154. 'with'                  _non_alpha_                 pt_RESERVED
  155. 'packed'                _non_alpha_                 pt_RESERVED
  156. 'implementation'        _non_alpha_                 pt_RESERVED
  157. 'interface'             _non_alpha_                 pt_RESERVED
  158. 'unit'                  _non_alpha_                 pt_RESERVED
  159. 'uses'                  _non_alpha_                 pt_RESERVED
  160. 'as'                    _non_alpha_                 pt_RESERVED
  161. 'on'                    _non_alpha_                 pt_RESERVED
  162. 'asm'                   _non_alpha_                 pt_RESERVED
  163. 'class'                 _non_alpha_                 pt_RESERVED
  164. 'constructor'           _non_alpha_                 pt_RESERVED
  165. 'destructor'            _non_alpha_                 pt_RESERVED
  166. 'except'                _non_alpha_                 pt_RESERVED
  167. 'exports'               _non_alpha_                 pt_EXPORTS
  168. 'finalization'          _non_alpha_                 pt_RESERVED
  169. 'finally'               _non_alpha_                 pt_RESERVED
  170. 'inherited'             _non_alpha_                 pt_RESERVED
  171. 'initialization'        _non_alpha_                 pt_RESERVED
  172. 'inline'                _non_alpha_                 pt_RESERVED
  173. 'is'                    _non_alpha_                 pt_RESERVED
  174. 'library'               _non_alpha_                 pt_RESERVED
  175. 'object'                _non_alpha_                 pt_RESERVED
  176. 'property'              _non_alpha_                 pt_PROPERTY
  177. 'raise'                 _non_alpha_                 pt_RESERVED
  178. 'shl'                   _non_alpha_                 pt_RESERVED
  179. 'shr'                   _non_alpha_                 pt_RESERVED
  180. 'threadvar'             _non_alpha_                 pt_RESERVED
  181. 'try'                   _non_alpha_                 pt_RESERVED
  182. 'xor'                   _non_alpha_                 pt_RESERVED
  183. 'absolute'              _non_alpha_                 pt_RESERVED
  184. 'abstract'              _non_alpha_                 pt_RESERVED
  185. 'assembler'             _non_alpha_                 pt_RESERVED
  186. 'at'                    _non_alpha_                 pt_RESERVED
  187. 'automated'             _non_alpha_                 pt_RESERVED
  188. 'cdecl'                 _non_alpha_                 pt_RESERVED
  189. 'default'               _non_alpha_                 pt_DEFAULT_TOKEN [ss_PROPERTY]
  190. 'dispid'                _non_alpha_                 pt_RESERVED
  191. 'dynamic'               _non_alpha_                 pt_RESERVED
  192. 'external'              _non_alpha_                 pt_RESERVED
  193. 'index'                 _non_alpha_                 pt_INDEX       [ss_EXPORTS]
  194. 'message'               _non_alpha_                 pt_RESERVED
  195. 'name'                  _non_alpha_                 pt_NAME        [ss_EXPORTS]
  196. 'nodefault'             _non_alpha_                 pt_RESERVED
  197. 'override'              _non_alpha_                 pt_RESERVED
  198. 'pascal'                _non_alpha_                 pt_RESERVED
  199. 'private'               _non_alpha_                 pt_RESERVED
  200. 'protected'             _non_alpha_                 pt_RESERVED
  201. 'public'                _non_alpha_                 pt_RESERVED
  202. 'published'             _non_alpha_                 pt_RESERVED
  203. 'read'                  _non_alpha_                 pt_READ        [ss_PROPERTY]
  204. 'register'              _non_alpha_                 pt_RESERVED
  205. 'resident'              _non_alpha_                 pt_RESIDENT    [ss_EXPORTS]
  206. 'resourcestring'        _non_alpha_                 pt_RESERVED
  207. 'stdcall'               _non_alpha_                 pt_RESERVED
  208. 'stored'                _non_alpha_                 pt_STORED      [ss_PROPERTY]
  209. 'virtual'               _non_alpha_                 pt_RESERVED
  210. 'write'                 _non_alpha_                 pt_WRITE       [ss_PROPERTY]
  211.  
  212. //--------------------------------------------------------------------------------------------------------------------
  213. //
  214. // %%handler section
  215. //
  216. // The %%handler section gives rules to be applied once an entry in the %%words table has been recognised. Normally
  217. // no further processing is required but sometimes a token starts with a fixed set of characters but may be followed
  218. // by a character class rather than a known sequence.
  219. //
  220. // %%handler table entries have 4 columns:
  221. //     Column 1          Token value to be processed
  222. //     Column 2          Character specifier that follows recognised word
  223. //     Column 3          Quoted string specifying end sequence
  224. //     Column 4          Whether end sequence is part of lexeme
  225. //
  226. // The <character specifier> is defined as:
  227. //     Column 2          A single character specifier or pre-defined system character macro:
  228. //                         _PASCAL_CHAR         Pascal style character specifier
  229. //                         _C_CHAR              C style character specifier
  230. //                       If the lexeme can optionally have these characters then append '?' to the end
  231. //                       of the quoted string.
  232. //     Column 3          Up to 2 characters may be given as a sequence to terminate the lexeme.
  233. //                       Characters are specified using a simplified regular expression. If this
  234. //                       string is empty then the lexeme will never be matched.
  235. //
  236. %%handler
  237. pt_COMMENT_LINE           '[^\n]'?                    '\n'           _discard_
  238. pt_COMMENT_BRACE          '[^}]'?                     '}'            _use_
  239. pt_COMMENT_STAR           _all_chars_?                '*)'           _use_
  240. pt_CHAR_DECIMAL           _dec_digit_                 '[^0-9]'       _discard_
  241. pt_CHAR_HEX               _hex_digit_                 '[^a-fA-F0-9]' _discard_
  242.  
  243. //--------------------------------------------------------------------------------------------------------------------
  244. //
  245. // %%tokens section
  246. //
  247. // Used to specify how to recognise non-fixed lexemes. Non-fixed lexemes are only tried if the table entries in the
  248. // %%words section have failed. The non-fixed lexeme is defiened by 5 columns as below:
  249. //     Column 1          Token value
  250. //     Column 2          Single start character specifier
  251. //     Column 3          Single contains character specifier
  252. //     Column 4          End sequence specifier
  253. //     Column 5          Whether end sequence is part of lexeme
  254. // Pre-defined token styles are implemented. If used they should be specified in Column 2. The implemented ones
  255. // are:
  256. //  __STD_PASCALSTRING   Pascal string -- starts with ' ands with ' and uses '' to represent
  257. //                       ' within a string. Does not extend beywond end of line.
  258. //  __STD_IDENTIFIER     Standard identifier. Starts with [_a-zA-Z], contains [_a-zA-Z0-9] and ends with
  259. //                       a non-alpha numeric character that is not part of the lexeme
  260. //  __STD_NUMBER_OR_FP   Integer or floating point constant of syntax:
  261. //                           <Digit String> [ '.' <Digit string> ] [ e|E [+-] <Digit string> ]
  262. //
  263. %%tokens
  264. pt_HEXNUMBER            '$'                         '[0-9a-fA-F]'       '[^0-9a-fA-F]'        _discard_
  265. pt_STRING               __STD_PASCALSTRING
  266. pt_IDENTIFIER           __STD_IDENTIFIER
  267. pt_NUMBER               __STD_NUMBER_OR_FP
  268. pt_DEFAULT              '[\s\t\n]'                  '[\s\t\n]'          '[^\s\t\n]'           _discard_
  269.  
  270.  
  271. //--------------------------------------------------------------------------------------------------------------------
  272. //
  273. // %%effects section
  274. //
  275. // Used to specify the default colors and font styles used for each token
  276. //
  277. //     Column 1          Token value
  278. //     Column 2          Font styles
  279. //     Column 3          Foreground color
  280. //     Column 4          Background color
  281. //     Column 5          Optional column specifying whether map entry is a 'hotspot'
  282. //
  283. // Columns 1-4 must be completed for all rows, Column 5 defaults to non-hotspot.
  284. //
  285. %%effects
  286. pt_DEFAULT              []                          _DEFAULT_FOREGROUND         _DEFAULT_BACKGROUND
  287. pt_IDENTIFIER           []                          _DEFAULT_FOREGROUND         _DEFAULT_BACKGROUND
  288. pt_STRING               []                          clMaroon                    _DEFAULT_BACKGROUND
  289. pt_COMMENT              [fsItalic]                  clPurple                    _DEFAULT_BACKGROUND
  290. pt_RESERVED             [fsBold]                    clNavy                      _DEFAULT_BACKGROUND
  291. pt_NUMBER               []                          clGreen                     _DEFAULT_BACKGROUND
  292. pt_SYMBOL               []                          _DEFAULT_FOREGROUND         _DEFAULT_BACKGROUND
  293.  
  294.  
  295.  
  296. //--------------------------------------------------------------------------------------------------------------------
  297. //
  298. // %%map section
  299. //
  300. // Used to specify which entry in the %%effects table each token value uses. By default all token values map onto
  301. // __DEFAULT_TOKEN which is defined as zero. Table has 2 columns:
  302. //     Column 1          Recognised token value
  303. //     Column 2          Map table entry (i.e. %%effects table entry)
  304. // Normally the %%map table consists of identical value entries.
  305. %%map
  306. pt_IDENTIFIER           pt_IDENTIFIER
  307. pt_STRING               pt_STRING
  308. pt_HEXNUMBER            pt_NUMBER
  309. pt_NUMBER               pt_NUMBER
  310. pt_COMMENT              pt_COMMENT
  311. pt_COMMENT_LINE         pt_COMMENT
  312. pt_COMMENT_STAR         pt_COMMENT
  313. pt_COMMENT_BRACE        pt_COMMENT
  314. pt_RESERVED             pt_RESERVED
  315. pt_SYMBOL               pt_SYMBOL
  316. pt_SEMICOLON            pt_SYMBOL
  317. pt_PROPERTY             pt_RESERVED
  318. pt_READ                 pt_RESERVED
  319. pt_WRITE                pt_RESERVED
  320. pt_DEFAULT_TOKEN        pt_RESERVED
  321. pt_STORED               pt_RESERVED
  322. pt_EXPORTS              pt_RESERVED
  323. pt_NAME                 pt_RESERVED
  324. pt_INDEX                pt_RESERVED
  325. pt_RESIDENT             pt_RESERVED
  326. pt_CHAR_DECIMAL         pt_STRING
  327. pt_CHAR_HEX             pt_STRING
  328.  
  329.  
  330. %%states
  331. pt_PROPERTY             (+[ss_PROPERTY] -[ss_START])
  332. pt_SEMICOLON            (+[ss_START]    -[ss_PROPERTY ss_EXPORTS])
  333. pt_EXPORTS              (+[ss_EXPORTS])
  334.